Ext.define("component.proces.history",{
	extend : 'Ext.panel.Panel',
	config : {
		processInstanceId : ''
	},
	setAutidStatusName:function(auditStatus){
		if(auditStatus=="" || auditStatus==null){
			Ext.getCmp("currAuditStatus").setVisible(false);
			return;
		}
		var currAutidStatus = "";
		if(auditStatus == "0"){
			currAuditStatus = "<font style='color: red;'>待提交</font>";
		}else if(auditStatus == "1"){
			currAuditStatus = "<font style='color: red;'>审核中</font>";
		}else if(auditStatus == "2"){
			currAuditStatus = "<font style='color: red;'>已退回</font>";
		}else if(auditStatus == "3"){
			currAuditStatus = "<font style='color: red;'>已通过</font>";
		}
	 	Ext.getCmp("currAuditStatus").setValue(currAuditStatus);
	},
	setProcesHistoryVisible:function(processFlag){
		if(processFlag=="true" || processFlag==true){
			Ext.getCmp("historyPanel").setVisible(false);
		}
	},
	initComponent : function() {
		var me = this;
		var processInstanceId = this.processInstanceId;
		var gridStore = Ext.create('Ext.data.Store', {
		    fields: ["taskName","taskUserName","taskCheckStatus", "startDate", "endDate"],
		    //是否在服务端排序 （true的话，在客户端就不能排序）
		    remoteSort: false,
		    proxy: {
		        type: 'ajax',
		        url: contextPath+'/processComponent/queryHistoricActivity',
		        reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
		            type: 'json', //返回数据类型为json格式
		            root: 'obj',  //数据
		            totalProperty: 'total' //数据总条数
		        },
		        extraParams:{
		        	processInstanceId:processInstanceId
		        }
		    }
		});
		
		
		var columns = [{
			text : "任务名称",
			dataIndex : 'taskName',
			width:'20%'
		}, {
			text : "参与人员",
			dataIndex : 'taskUserName',
			width:'20%'
		}, {
			text : "状态",
			dataIndex : 'taskCheckStatus',
			width:'20%'
		}, {
			text : "开始时间",
			dataIndex : 'startDate',
			width:'20%',
			renderer : function(val) {
				if(val){
					return Ext.Date.format(new Date(val),'Y-m-d H:i:s')
				}
				return "";
			}
		}, {
			text : "结束时间",
			dataIndex : 'endDate',
			width:'20%',
			renderer : function(val) {
				if(val){
					return Ext.Date.format(new Date(val),'Y-m-d H:i:s')
				}
				return "";
			}
		}];
		
		
		var mainPanel=Ext.create('Ext.grid.Panel', {
			title:"审批历史",
			height:'300',
			store : gridStore,
			columns : columns,
			dockedItems: [{
	            dock: 'top',
	            xtype: 'toolbar',
	            items: [{
	                width: 400,
	                fieldLabel: '当前审核状态',
	                labelWidth: 100,
	                xtype: 'displayfield',
	                name: "currAuditStatus",
	                id: "currAuditStatus"
	            }]
	        }]
		});
		var defaultConfig = {
				defaults: {  
		            split: true,    //有分割线  
		            collapsible: true  //可以折叠
		        },
		        id:'historyPanel',
			items:[mainPanel]
		};
		gridStore.load();
		Ext.apply(this,defaultConfig);
		this.callParent();
		
	},collapsible:false
	
});